package b3.widget.home
{
	import b3.net.ResourceHelper;
	import b3.util.BSound;
	import b3.widget.basic.BasicButton;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class MusicIcon extends BasicButton
	{
		private var disableSprite:Sprite;
		
		public function MusicIcon()
		{
			var IconImg:Class = ResourceHelper.getInstance().getClassByName("MusicIcon");
			super(IconImg, null, 15, 28, 28);
			disableSprite = new Sprite();
			disableSprite.graphics.lineStyle(4,0xaaaaff);
			disableSprite.graphics.moveTo(4,4);
			disableSprite.graphics.lineTo(24,24);
			this.addChild(disableSprite);
			disableSprite.visible = false;
			addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		private function onMouseClick(event:MouseEvent):void
		{
			disableSprite.visible = !disableSprite.visible;
			BSound.getInstance().musicVolume = disableSprite.visible ? 0 : 1;
		}
	}
}